package com.ambulance.project.biz.controller.manager;

import com.ambulance.common.utils.poi.ExcelUtil;
import com.ambulance.framework.aspectj.lang.annotation.Log;
import com.ambulance.framework.aspectj.lang.enums.BusinessType;
import com.ambulance.framework.web.controller.BaseController;
import com.ambulance.framework.web.domain.AjaxResult;
import com.ambulance.framework.web.page.TableDataInfo;
import com.ambulance.project.manager.domain.BizDispatchnotice;
import com.ambulance.project.manager.service.IBizDispatchnoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 调度通知Controller
 *
 * @author zr
 * @date 2020-05-11
 */
@RestController
@RequestMapping("/manager/dispatchNotice")
public class BizDispatchnoticeController extends BaseController {
    @Autowired
    private IBizDispatchnoticeService bizDispatchnoticeService;

    /**
     * 查询调度通知列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchNotice:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDispatchnotice bizDispatchnotice) {
        startPage();
        List<BizDispatchnotice> list = bizDispatchnoticeService.selectBizDispatchnoticeList(bizDispatchnotice);
        return getDataTable(list);
    }

    /**
     * 导出调度通知列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchNotice:export')")
    @Log(title = "调度通知", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizDispatchnotice bizDispatchnotice) {
        List<BizDispatchnotice> list = bizDispatchnoticeService.selectBizDispatchnoticeList(bizDispatchnotice);
        ExcelUtil<BizDispatchnotice> util = new ExcelUtil<BizDispatchnotice>(BizDispatchnotice.class);
        return util.exportExcel(list, "dispatchNotice");
    }

    /**
     * 获取调度通知详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchNotice:query')")
    @GetMapping(value = "/{noticeID}")
    public AjaxResult getInfo(@PathVariable("noticeID") Long noticeID) {
        return AjaxResult.success(bizDispatchnoticeService.selectBizDispatchnoticeById(noticeID));
    }

    /**
     * 新增调度通知
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchNotice:add')")
    @Log(title = "调度通知", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizDispatchnotice bizDispatchnotice) {
        return toAjax(bizDispatchnoticeService.insertBizDispatchnotice(bizDispatchnotice));
    }

    /**
     * 修改调度通知
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchNotice:edit')")
    @Log(title = "调度通知", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizDispatchnotice bizDispatchnotice) {
        return toAjax(bizDispatchnoticeService.updateBizDispatchnotice(bizDispatchnotice));
    }

    /**
     * 删除调度通知
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchNotice:remove')")
    @Log(title = "调度通知", businessType = BusinessType.DELETE)
    @DeleteMapping("/{noticeIDs}")
    public AjaxResult remove(@PathVariable Long[] noticeIDs) {
        return toAjax(bizDispatchnoticeService.deleteBizDispatchnoticeByIds(noticeIDs));
    }
}
